import 'package:flutter_demo/core/common/values/server.dart';
import 'package:flutter_demo/core/route/app_routes.dart';
import 'package:flutter_demo/ui/pages/web/web_view.dart';
import 'package:get/get.dart';

class RouteUtils {
  static Future<void> routeFromActionStr(String? action, {dynamic data}) async {
    if (action == null) return;
    logger.d(action);
    if (action.startsWith(Routes.APP)) {
      //应用内跳转
      final path = action.substring(Routes.APP.length, action.length);
      Get.toNamed('/$path');
      return;
    } else if (action.startsWith(Routes.WEB)) {
      final path = action.substring(Routes.WEB.length, action.length);
      //跳转web页面
      Get.toNamed("${WebPage.routeName}?url=$path");
    } else {
      Get.snackbar("", action);
    }
  }
}
